# 抖码算法，让算法学习变得简单有趣
# 作者：老汤

# 这道题目是 力扣 11 号题原题，
# 参考课程 B：https://yjs.xet.tech/s/2f4iKr


# 1. 处理输入，将输入转成整形数组
height_line = str(input()).split(",")
heights = [0] * len(height_line)
for i in range(len(height_line)):
    heights[i] = int(height_line[i])

# 2. 双指针求解
left, right, ans = 0, len(heights) - 1, 0
while left < right:
    area = min(heights[left], heights[right]) * (right - left)
    ans = max(ans, area)
    if heights[left] <= heights[right]:
        left += 1
    else:
        right -= 1

print(ans)